//
//  HomePageTableViewModel.m
//  InSuger
//
//  Created by dllo on 15/11/26.
//  Copyright © 2015年 Dior_3g. All rights reserved.
//

#import "HomePageTableViewModel.h"

@implementation HomePageTableViewModel

- (void)setValue:(id)value forUndefinedKey:(NSString *)key {
    
    if ([key isEqualToString:@"id"]) {
        self.tableId = value;
    }
    
}

- (void)encodeWithCoder:(NSCoder *)aCoder {
    
    [aCoder encodeObject:self.pic forKey:@"pic"];
    [aCoder encodeObject:self.title forKey:@"title"];
    [aCoder encodeObject:self.likes forKey:@"likes"];
    [aCoder encodeObject:self.tableId forKey:@"tableId"];
    
}

- (id)initWithCoder:(NSCoder *)aDecoder {
    
    self = [super init];
    if (self) {
        
        //      解码的操作
        //      把解码之后的值再赋值给属性
        
        self.pic = [aDecoder decodeObjectForKey:@"pic"];
        self.title = [aDecoder decodeObjectForKey:@"title"];
        self.likes = [aDecoder decodeObjectForKey:@"likes"];
        self.tableId = [aDecoder decodeObjectForKey:@"tableId"];
        
    }
    return self;
    
}

- (instancetype)initWithPic:(NSString *)pic title:(NSString *)title likes:(NSNumber *)likes tableId:(NSString *)tableId {
    
    self = [super init];
    
    if (self) {
        
        self.pic = pic;
        self.title = title;
        self.likes = likes;
        self.tableId = tableId;
        
    }
    return self;
    
}

@end
